package Flyweight;

import java.util.HashMap;

public class PieceFactory {
    private HashMap piecePool = new HashMap();

    public AbstractPiece getPiece(String key)
    {
        if(!piecePool.containsKey(key))
        {
            AbstractPiece p = new Piece(key);
            piecePool.put(key,p);
            return p;
        }
        return (AbstractPiece)piecePool.get(key);
    }

    public int getPieceCount()
    {
        return piecePool.size();
    }

}
